<?php
include("../includes/common.php");
if($islogin2==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");
include './head.php';
$uid=$rs=$DB->query("select * from pay_user WHERE name={$pid}"); 
foreach($uid as $res){
 $usid=$res['id'];
}
$numrows=$DB->query("SELECT * from pay_cement WHERE `active` = 0")->rowCount();
$pagesize=20;
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
{
    $pages++;
}
if (isset($_GET['page'])){
    $page=intval($_GET['page']);
}
else{
    $page=1;
}
$offset=$pagesize*($page - 1);
$rs=$DB->query("SELECT * FROM `pay_cement` WHERE `active` = 0 order by id desc limit $offset,$pagesize")->fetchAll();
?>
<div class="clearfix"></div>
  <div class="content-wrapper">
    <div class="container-fluid">  
     <div class="row pt-2 pb-2">
        <div class="col-sm-9">
		    <h4 class="page-title">公告列表</h4>
		    <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="javaScript:void();">公告</a></li>
            <li class="breadcrumb-item"><a href="javaScript:void();">列表</a></li>
            <li class="breadcrumb-item active" aria-current="page">信息</li>
         </ol>
	   </div>
      </div>
     </div>
      <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-header"><i class="fa fa-table"></i>公告列表</div>
            <div class="card-body">
              <div class="table-responsive">
              <table id="default-datatable" class="table table-bordered">
                <thead>
                    <tr>
                        <th>公告标题</th>
                        <th>公告内容</th>
                        <th>发布时间</th>
                        <th>发布者</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <?php
                 $f = 0;
                    foreach ($rs as $row){
                  
                  ?>
               <tr>
                        <td><?php echo $row['title'];?></td>
                        <td><?php echo mb_substr($row['content'], 0, 25, 'utf-8')?>.........<br></td>
                        <td><?php echo $row['time'];?></td>
                        <td><?php echo $row['usernane'];?></td>
                    <td><a id="check_notice<?=$f?>"><span class="badge badge-pill badge-danger m-1">查看</a></td>
                    <button name="title<?=$f?>" hidden="hidden" value="<?=$row['title']?>"></button>
                    <button name="content<?=$f?>" hidden="hidden" value="<?=$row['content']?>"></button>
                    <button name="time<?=$f?>" hidden="hidden" value="<?=$row['time']?>"></button>
                    <button name="usernane<?=$f?>" hidden="hidden" value="<?=$row['usernane']?>"></button>
                    </tr>
                     <?php
                            $f++;
                            } ?>
                </tbody>
            </table>
            </div>
            </div>
            <?php

         
          echo'<ul class="pagination">';
                        $first=1;
                        $prev=$page-1;
                        $next=$page+1;
                        $last=$pages;
                        if ($page>1)
                        {
                            echo '<li class="page-item"><a class="page-link" href="userge.php?page='.$first.$link.'">首页</a></li>';
                            echo '<li class="page-item"><a class="page-link" href="userge.php?page='.$prev.$link.'">&laquo;</a></li>';
                        } else {
                            echo '<li class="page-item"><a class="page-link">首页</a></li>';
                            echo '<li class="page-item"><a class="page-link">&laquo;</a></li>';
                        }
                        for ($i=1;$i<$page;$i++)
                            echo '<li class="page-item"><a class="page-link" href="userge.php?page='.$i.$link.'">'.$i .'</a></li>';
                        echo '<li class="page-item"><a class="page-link">'.$page.'</a></li>';
                        if($pages>=10)$pages=10;
                        for ($i=$page+1;$i<=$pages;$i++)
                            echo '<li class="page-item"><a class="page-link" href="userge.php?page='.$i.$link.'">'.$i .'</a></li>';
                        echo '';
                        if ($page<$pages)
                        {
                            echo '<li class="page-item"><a class="page-link" href="userge.php?page='.$next.$link.'">&raquo;</a></li>';
                            echo '<li class="page-item"><a class="page-link" href="userge.php?page='.$last.$link.'">尾页</a></li>';
                        } else {
                            echo '<li class="page-item"><a class="page-link">&raquo;</a></li>';
                            echo '<li class="page-item"><a class="page-link">尾页</a></li>';
                        }
                        echo'</ul>';
                      
                    
?>
          </div>
        </div>
      </div>
    </div>
    </div>
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    
  </div>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/jquery.dataTables.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/dataTables.buttons.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/buttons.bootstrap4.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/jszip.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/pdfmake.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/vfs_fonts.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/buttons.html5.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/buttons.print.min.js"></script>
  <script src="/user/kuyun/plugins/bootstrap-datatable/js/buttons.colVis.min.js"></script>
<script>

 <?php
    $f1 = 0;
    foreach ($rs as $row){
    ?>
    $("#check_notice<?=$f1?>").click(function(){
        var title = $("button[name='title<?=$f1?>']").val();
        var content = $("button[name='content<?=$f1?>']").val();
        var time = $("button[name='time<?=$f1?>']").val();
        var usernane = $("button[name='usernane<?=$f1?>']").val();
        layer.open({
           type:1,
             area:['420px','260px'],
            btn:['关闭'],
            title:title,
             content:'<ul class="list-group">' +
                 '<li class="list-group-item list-group-item-primary">' +
                '标题：'+title +'<br />' +
                 '内容：'+content+'<br />' +
                 '发布时间：'+time+
                '发布者：'+usernane+'<br />' +
                 '</ul>'
        });
    });

    <?php
    $f1++;
    } ?>

    </script>
<?php include 'foot.php';?>